<html>
<head><meta charset="utf-8"><title>MCP: Rust-style `#[inline]` attribute. lang-team#56 · t-lang/major changes · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/index.html">t-lang/major changes</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html">MCP: Rust-style `#[inline]` attribute. lang-team#56</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="210623728"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210623728" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> triagebot <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210623728">(Sep 19 2020 at 16:41)</a>:</h4>
<p>A new proposal has been announced: <a href="https://github.com/rust-lang/lang-team/issues/56">MCP: Rust-style <code>#[inline]</code> attribute. #56</a>. It will be announced at the next meeting to try and draw attention to it, but usually MCPs are not discussed during triage meetings. If you think this would benefit from discussion amongst the team, consider proposing a design meeting.</p>



<a name="210623883"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210623883" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210623883">(Sep 19 2020 at 16:44)</a>:</h4>
<blockquote>
<p>** #[inline] -&gt; try the compiler's best to inline (always invoke MIR inliner), keep silent when failing to do so (and tag as alwaysinline to ask llvm to try again).</p>
</blockquote>
<p>did you mean to say 'tag as inlinehint to ask to try again'? seems odd to mark <code>#[inline]</code> as <code>alwaysinline</code></p>



<a name="210623972"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210623972" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210623972">(Sep 19 2020 at 16:46)</a>:</h4>
<p>It feels like this should be a T-compiler MCP; I don't see why this needs lang team involvement modulo the lint suggestion.</p>



<a name="210623973"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210623973" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210623973">(Sep 19 2020 at 16:46)</a>:</h4>
<p>I think the claim is that <code>inlinehint</code> is not particularly useful</p>



<a name="210623987"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210623987" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210623987">(Sep 19 2020 at 16:46)</a>:</h4>
<p>But the lint seems good to add (much) later, when we can say things like "it rarely triggers" (or vice versa).</p>



<a name="210624007"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624007" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624007">(Sep 19 2020 at 16:47)</a>:</h4>
<p><span class="user-mention" data-user-id="232545">@Joshua Nelson</span>  I propose interpreting <code>#[inline]</code> as intentional and we should try our best to inline the function.</p>



<a name="210624011"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624011" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624011">(Sep 19 2020 at 16:47)</a>:</h4>
<p>(I also think that IIRC we don't have a working MIR inliner yet...?)</p>



<a name="210624020"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624020" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624020">(Sep 19 2020 at 16:47)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> There're related chapters in the reference. That's why i submitted this as a language mcp.</p>



<a name="210624093"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624093" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624093">(Sep 19 2020 at 16:49)</a>:</h4>
<p>I don't see that they would need to change (again modulo the lint that I think we're not prepared to discuss without an impl)</p>



<a name="210624165"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624165" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624165">(Sep 19 2020 at 16:51)</a>:</h4>
<p>I guess I'm not understanding the difference between <code>inline</code> and <code>inline(always)</code> in your proposal. Is the difference that <code>always</code> warns if it's inlined by llvm instead of Mir opts? That doesn't seem very useful</p>



<a name="210624173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624173">(Sep 19 2020 at 16:51)</a>:</h4>
<p>I think... I'm proposing change <code>#[inline]</code> from a hint to a requirement <a href="https://doc.rust-lang.org/nightly/reference/attributes/codegen.html?highlight=inline#the-inline-attribute">in the reference</a>.</p>



<a name="210624176"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624176" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624176">(Sep 19 2020 at 16:51)</a>:</h4>
<p>my question is higher-level: why do we need to change the language spec for this?</p>



<a name="210624183"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624183" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624183">(Sep 19 2020 at 16:51)</a>:</h4>
<p>I don't see what we get by making it a requirement</p>



<a name="210624186"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624186" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624186">(Sep 19 2020 at 16:51)</a>:</h4>
<p>I'd like to note that inline and inline(always) actually do make a <em>correctness</em> difference in the presence of cpu features. inline(always) <em>can</em> convince llvm to inline a different cpu featured function, while inline cannot.</p>



<a name="210624238"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624238" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624238">(Sep 19 2020 at 16:52)</a>:</h4>
<p><span class="user-mention" data-user-id="224471">@Lokathor</span> I think that's perhaps an llvm bug or "misfeature" in some sense though?</p>



<a name="210624243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624243">(Sep 19 2020 at 16:52)</a>:</h4>
<p>do you have an example?</p>



<a name="210624252"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624252" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624252">(Sep 19 2020 at 16:53)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> probably, but it's a danger either way</p>



<a name="210624270"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624270" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624270">(Sep 19 2020 at 16:53)</a>:</h4>
<p><span class="user-mention" data-user-id="271719">@Mario Carneiro</span> not offhand.</p>



<a name="210624314"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624314" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624314">(Sep 19 2020 at 16:54)</a>:</h4>
<p>How would a correctness bug occur here?</p>



<a name="210624315"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624315" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624315">(Sep 19 2020 at 16:54)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> For example, when user specify <code>#[inline]</code>, instead of heuristically calculating whether it might be beneficial at call site, we always just inline the call.</p>



<a name="210624316"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624316" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624316">(Sep 19 2020 at 16:54)</a>:</h4>
<p>I think it was <span class="user-mention" data-user-id="143274">@Amanieu</span> who pointed out to me that inline(always) can force a cross-feature inlining</p>



<a name="210624321"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624321" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624321">(Sep 19 2020 at 16:54)</a>:</h4>
<p>So we're no longer relying LLVM to decide.</p>



<a name="210624328"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624328" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624328">(Sep 19 2020 at 16:55)</a>:</h4>
<p><span class="user-mention" data-user-id="116458">@Charles Lew</span> my point is that we can do that in the compiler <em>now</em> without language spec changes (well, we could if MIR inlining worked...)</p>



<a name="210624338"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624338" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624338">(Sep 19 2020 at 16:55)</a>:</h4>
<p>but it's a pretty big requirement on compiler implementors to have to support this and doesn't seem hugely beneficial</p>



<a name="210624346"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624346" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624346">(Sep 19 2020 at 16:55)</a>:</h4>
<p>under what circumstances would inline or inline(always) fail? (My guess is only recursive functions.) In particular, can mir always detect such situations before turning it over to llvm?</p>



<a name="210624399"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624399" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624399">(Sep 19 2020 at 16:56)</a>:</h4>
<p>if so, then Joshua's concern about warning on inlining that mir fails to do and llvm succeeds wouldn't be an issue</p>



<a name="210624422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624422">(Sep 19 2020 at 16:57)</a>:</h4>
<p>my point is that we have failed to write a working MIR inliner for over 2 years now, and not fully through lack of effort</p>



<a name="210624459"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624459" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624459">(Sep 19 2020 at 16:58)</a>:</h4>
<p>so requiring every implementation of Rust to do it seems... overly harsh</p>



<a name="210624468"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624468" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624468">(Sep 19 2020 at 16:58)</a>:</h4>
<p>It is also possible to suppress the warning even if mir doesn't do the inlining as long as we are confident that llvm will</p>



<a name="210624487"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624487" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624487">(Sep 19 2020 at 16:59)</a>:</h4>
<p>Another high level point: I don't think Ilvm and mir should be written into the language spec</p>



<a name="210624492"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624492" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Joshua Nelson <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624492">(Sep 19 2020 at 16:59)</a>:</h4>
<p>What happens if you don't use llvm as a backend? What would the warning mean?</p>



<a name="210624501"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624501" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624501">(Sep 19 2020 at 17:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> <br>
The situation i want to improve is that:   Currently libstd <code>Option::map</code> has an <code>#[inline]</code> attribute, and currently rustc compiler doesn't know whether it will be inlined for a specific <code>T</code> type.</p>



<a name="210624533"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624533" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624533">(Sep 19 2020 at 17:00)</a>:</h4>
<p>The warning means we could not ensure that it was inlined</p>



<a name="210624548"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624548" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624548">(Sep 19 2020 at 17:00)</a>:</h4>
<p><span class="user-mention" data-user-id="116458">@Charles Lew</span> I am confused -- making this a language-level guarantee doesn't help with that at all?</p>



<a name="210624549"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624549" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624549">(Sep 19 2020 at 17:00)</a>:</h4>
<p>it should be correct for a rust implementation to never inline and just give a warning on every <code>inline(always)</code></p>



<a name="210624555"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624555" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624555">(Sep 19 2020 at 17:00)</a>:</h4>
<p>Inlining has user-visible effects in some cases: I use a combination of <code>#[inline(always)]</code> and <code>#[inline(never)]</code> to skip a fixed number of frames in my custom backtrace implementation. At the very least <code>#[inline(never)]</code> should be a hard guarantee.</p>



<a name="210624569"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624569" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624569">(Sep 19 2020 at 17:01)</a>:</h4>
<p>If the promise is that this will be always inlined, mir inliner can just go ahead and  inline it.</p>



<a name="210624575"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624575" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624575">(Sep 19 2020 at 17:01)</a>:</h4>
<p>it doesn't need to supply this to llvm inliner any more.</p>



<a name="210624590"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624590" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624590">(Sep 19 2020 at 17:02)</a>:</h4>
<p><span class="user-mention" data-user-id="116458">@Charles Lew</span> I don't understand I guess, MIR inlining isn't hard because we're not sure whether to inline or not</p>



<a name="210624663"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624663" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624663">(Sep 19 2020 at 17:03)</a>:</h4>
<p>Sorry, i'm not very familiar with the implementation details, maybe there're some deeper reasons?</p>



<a name="210624665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624665">(Sep 19 2020 at 17:04)</a>:</h4>
<p><em>If</em> we had a working inliner, then maybe this MCP would make more sense to me, though I do not find it personally convincing. I think I would prefer that we have other attributes for "no I really do need this to have a significant callframe for e.g. <span class="user-mention" data-user-id="143274">@Amanieu</span>'s case" or "yes, please do inline this so that the target CPU/feature attributes work out, for <span class="user-mention" data-user-id="224471">@Lokathor</span>'s case"</p>



<a name="210624711"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624711" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624711">(Sep 19 2020 at 17:04)</a>:</h4>
<p><span class="user-mention" data-user-id="116458">@Charles Lew</span> the reasons MIR inlining is hard have ~nothing to do with the language not guaranteeing inlining</p>



<a name="210624734"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624734" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624734">(Sep 19 2020 at 17:05)</a>:</h4>
<p>I'm with Amanieu, i want a "inline(absolutely_never)"</p>



<a name="210624745"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624745" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624745">(Sep 19 2020 at 17:05)</a>:</h4>
<p><code>#[inline(never)]</code> currently already does this, there is no need to change anything.</p>



<a name="210624788"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624788" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624788">(Sep 19 2020 at 17:06)</a>:</h4>
<p>Wouldn't <code>inline(always)</code> then just be the counterpoint to that?</p>



<a name="210624801"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624801" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Amanieu <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624801">(Sep 19 2020 at 17:06)</a>:</h4>
<p>I think there are some edge cases where <code>#[inline(always)]</code> will refuse to inline. I'll need to double-check.</p>



<a name="210624804"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624804" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624804">(Sep 19 2020 at 17:06)</a>:</h4>
<p>Currently <code>#[inline(never)]</code> is also a suggestion.</p>



<a name="210624807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624807">(Sep 19 2020 at 17:07)</a>:</h4>
<p>yeah i thought that inline(never) was a hint, and thus could potentially fail</p>



<a name="210624827"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624827" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624827">(Sep 19 2020 at 17:07)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="cp">#[inline(always)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w">  </span><span class="n">foo</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>definitely will fail...</p>



<a name="210624830"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624830" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624830">(Sep 19 2020 at 17:07)</a>:</h4>
<p>when I want <code>inline(always_really_no_joke)</code> I use a macro <span aria-label="shrug" class="emoji emoji-1f937" role="img" title="shrug">:shrug:</span></p>



<a name="210624903"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624903" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624903">(Sep 19 2020 at 17:09)</a>:</h4>
<p>recursive functions are pretty easy to detect though. It could either look for the pattern specifically or just use a depth limit</p>



<a name="210624908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624908">(Sep 19 2020 at 17:09)</a>:</h4>
<p>no, it's halting problem.</p>



<a name="210624923"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624923" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624923">(Sep 19 2020 at 17:10)</a>:</h4>
<p>huh? The call graph is statically known</p>



<a name="210624966"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624966" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624966">(Sep 19 2020 at 17:10)</a>:</h4>
<p>it's as hard as finding cycles in a graph</p>



<a name="210624967"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624967" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624967">(Sep 19 2020 at 17:10)</a>:</h4>
<div class="codehilite"><pre><span></span><code><span class="cp">#[inline(always)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">silly_true</span><span class="p">(</span><span class="n">first_landing</span>: <span class="kt">bool</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">first_entry</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="o">!</span><span class="n">silly_false</span><span class="p">(</span><span class="kc">false</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kc">true</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>

<span class="cp">#[inline(always)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">silly_false</span><span class="p">(</span><span class="n">first_landing</span>: <span class="kt">bool</span><span class="p">)</span><span class="w"> </span>-&gt; <span class="kt">bool</span> <span class="p">{</span><span class="w"></span>
<span class="w">    </span><span class="k">if</span><span class="w"> </span><span class="n">first_entry</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="o">!</span><span class="n">silly_true</span><span class="p">(</span><span class="kc">false</span><span class="p">)</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"> </span><span class="k">else</span><span class="w"> </span><span class="p">{</span><span class="w"></span>
<span class="w">        </span><span class="kc">false</span><span class="w"></span>
<span class="w">    </span><span class="p">}</span><span class="w"></span>
<span class="p">}</span><span class="w"></span>
</code></pre></div>



<a name="210624986"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624986" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624986">(Sep 19 2020 at 17:10)</a>:</h4>
<p>yeah that's a recursive function</p>



<a name="210624999"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210624999" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210624999">(Sep 19 2020 at 17:11)</a>:</h4>
<p>for example, this can and should be inlined successfully intuitively.</p>



<a name="210625010"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625010" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625010">(Sep 19 2020 at 17:11)</a>:</h4>
<p>Not really, you are relying on a certain order of operations to ensure that</p>



<a name="210625018"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625018" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625018">(Sep 19 2020 at 17:11)</a>:</h4>
<p>there are definitely nonterminating reduction strategies on that code</p>



<a name="210625061"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625061" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625061">(Sep 19 2020 at 17:12)</a>:</h4>
<p>but for all input they both terminates...</p>



<a name="210625065"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625065" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625065">(Sep 19 2020 at 17:12)</a>:</h4>
<p>"can", yes. "should", absolutely not unless you want to try to legislate the halting problem</p>



<a name="210625080"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625080" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625080">(Sep 19 2020 at 17:13)</a>:</h4>
<p>Who cares if they terminate on all inputs, we're not running the code we're inlining it</p>



<a name="210625142"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625142" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625142">(Sep 19 2020 at 17:14)</a>:</h4>
<p>in order to successfully inline that code you have to do a bit of inlining, then a bit of constant propagation, then a bit of dead code elimination, in that order</p>



<a name="210625143"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625143" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625143">(Sep 19 2020 at 17:14)</a>:</h4>
<p>if you do inlining then inlining then inlining some more then you fail to halt</p>



<a name="210625163"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625163" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625163">(Sep 19 2020 at 17:15)</a>:</h4>
<p>so from a language design perspective you really have to say "that's recursive, <code>inline(always)</code> not allowed"</p>



<a name="210625204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625204">(Sep 19 2020 at 17:16)</a>:</h4>
<p>Yes, indeed! That's why i want to lift this to language level.</p>



<a name="210625208"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625208" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625208">(Sep 19 2020 at 17:16)</a>:</h4>
<p>Currently mir-optimizer can partially support this. That's why i guess <span class="user-mention silent" data-user-id="116122">simulacrum</span> said MIR inlining is hard.</p>



<a name="210625218"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625218" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625218">(Sep 19 2020 at 17:16)</a>:</h4>
<p>lifting it to language level seems to just hurt though?</p>



<a name="210625234"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625234" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625234">(Sep 19 2020 at 17:17)</a>:</h4>
<p>No the compiler just tell user, you can't do this.</p>



<a name="210625243"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625243" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625243">(Sep 19 2020 at 17:17)</a>:</h4>
<p>No longer relying on "best effort".</p>



<a name="210625248"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625248" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625248">(Sep 19 2020 at 17:17)</a>:</h4>
<p>I think there is value in letting the user mandate the inlining and warn/error if it failed due to the compiler not being smart enough</p>



<a name="210625301"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625301" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625301">(Sep 19 2020 at 17:18)</a>:</h4>
<p>I don't disagree that there could be value in that</p>



<a name="210625311"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625311" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625311">(Sep 19 2020 at 17:18)</a>:</h4>
<p>like what else could <code>inline(always)</code> even mean?</p>



<a name="210625320"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625320" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625320">(Sep 19 2020 at 17:19)</a>:</h4>
<p>Today, it's "just" a stronger hint than <code>#[inline]</code> in some sense</p>



<a name="210625331"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625331" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625331">(Sep 19 2020 at 17:19)</a>:</h4>
<p>I guess -- all I'm saying -- is that I would prefer to wait on trying to specify warnings on never/always <em>until</em> we have a way of actually implementing those warnings that's not "pretty much always lints"</p>



<a name="210625380"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625380" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625380">(Sep 19 2020 at 17:20)</a>:</h4>
<p>I would hope that the success rate on these attributes is higher than that</p>



<a name="210625382"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625382" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625382">(Sep 19 2020 at 17:20)</a>:</h4>
<p>and it also seems likely that it'll just mean really-hard-to-close bugs of "LLVM was told not to inline but decided to anyway"</p>



<a name="210625387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625387">(Sep 19 2020 at 17:20)</a>:</h4>
<p>my point is that the current impl basically can't provide any certainty here</p>



<a name="210625412"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625412" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625412">(Sep 19 2020 at 17:21)</a>:</h4>
<p>that part actually does sound like a language change, of a sort. It means we take responsibility for any such LLVM bugs as rust bugs too</p>



<a name="210625418"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625418" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625418">(Sep 19 2020 at 17:21)</a>:</h4>
<p>Exactly</p>



<a name="210625453"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625453" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625453">(Sep 19 2020 at 17:22)</a>:</h4>
<p>indeed</p>



<a name="210625462"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625462" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625462">(Sep 19 2020 at 17:22)</a>:</h4>
<p>and I think we're basically not in a position to do so (yet)</p>



<a name="210625467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625467">(Sep 19 2020 at 17:22)</a>:</h4>
<p>and I'm not sure we'd ever want to take such responsibility for inlining decisions</p>



<a name="210625506"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625506" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625506">(Sep 19 2020 at 17:24)</a>:</h4>
<p>ok... and mcp is just a proposal. i just want to evaluate the possibility here.</p>



<a name="210625541"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625541" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625541">(Sep 19 2020 at 17:24)</a>:</h4>
<p>There are plenty of other language elements that are not negotiable from the compiler's POV, e.g. write order on volatile variables. Why should inlining be any different, being always subject to some compiler fuzziness?</p>



<a name="210625568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625568">(Sep 19 2020 at 17:25)</a>:</h4>
<p>The two feel different to me - maybe they shouldn't. Not sure.</p>



<a name="210625571"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625571" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625571">(Sep 19 2020 at 17:25)</a>:</h4>
<p>might be worth some research on LLVM design to see how insistent we can get</p>



<a name="210625624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625624">(Sep 19 2020 at 17:26)</a>:</h4>
<p>it would be great if there was some simple criterion that we could test (e.g. recursive function) outside of which LLVM can actually guarantee inlining</p>



<a name="210625625"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625625" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625625">(Sep 19 2020 at 17:26)</a>:</h4>
<p>Given that we have two different mechanisms, one to hint at inlining, and one to force inlining, what is the goal you're trying to achieve by turning the existing inline hint into a second mechanism to force?</p>



<a name="210625654"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625654" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625654">(Sep 19 2020 at 17:27)</a>:</h4>
<p>the first is almost not doing anything. (actually it does lift the tolerate value a little, but that's ignorable)</p>



<a name="210625657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625657">(Sep 19 2020 at 17:27)</a>:</h4>
<p>How valuable are inlining hints anyway? I always assumed (from C++ experience) that compilers take one look at it and say "heh, we'll see about that!"</p>



<a name="210625703"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625703" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625703">(Sep 19 2020 at 17:28)</a>:</h4>
<p>If that's the issue, then perhaps we should just tweak the hint threshold values or similar, or work with LLVM to do so.</p>



<a name="210625714"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625714" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625714">(Sep 19 2020 at 17:28)</a>:</h4>
<p>For a threshold tweaking hint I would prefer something more quantitative like <code>inline(+3.5)</code></p>



<a name="210625725"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625725" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625725">(Sep 19 2020 at 17:29)</a>:</h4>
<p>That seems like way more information than we should expose at the surface area of the language.</p>



<a name="210625743"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625743" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625743">(Sep 19 2020 at 17:29)</a>:</h4>
<p>I really can't imagine any scenario in which a person would have enough information to set that in a useful manner.</p>



<a name="210625772"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625772" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625772">(Sep 19 2020 at 17:30)</a>:</h4>
<p>I don't think that users are really in a position to give those values, which is part of the reason compiler writers turn their noses up at inlining "hints"</p>



<a name="210625805"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625805" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625805">(Sep 19 2020 at 17:30)</a>:</h4>
<p>I don't think <em>that</em> is the reason. and I don't think it's a foregone conclusion that compiler writers don't like hints.</p>



<a name="210625809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625809">(Sep 19 2020 at 17:30)</a>:</h4>
<p>It may just be that they're not currently doing a very good job with them. ;)</p>



<a name="210625812"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625812" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625812">(Sep 19 2020 at 17:30)</a>:</h4>
<p>which is why I'm fine with the general direction of this MCP, where your only options are "yes, no, compiler decide for me"</p>



<a name="210625831"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625831" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625831">(Sep 19 2020 at 17:31)</a>:</h4>
<p>instead of "no, probably yes, compiler decide for me, compiler decide for me but consider yes"</p>



<a name="210625835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625835">(Sep 19 2020 at 17:31)</a>:</h4>
<p>I would certainly be in favor of having a clear error if you use "always" and it can't be inlined.</p>



<a name="210625884"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625884" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625884">(Sep 19 2020 at 17:32)</a>:</h4>
<p>Whereas the usual inline directive shouldn't complain if it can't inline for some reasonable reason.</p>



<a name="210625894"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210625894" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210625894">(Sep 19 2020 at 17:32)</a>:</h4>
<p>If you're using "always", there may be some semantically significant reason for it.</p>



<a name="210628454"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210628454" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210628454">(Sep 19 2020 at 18:30)</a>:</h4>
<p>It is worth noting that <code>#[inline]</code> isn't just LLVM <code>inlinehint</code>. It also compiles the function into every crate compilation unit, even if it's non-generic, such that it _can_ be inlined.</p>



<a name="210628552"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210628552" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210628552">(Sep 19 2020 at 18:32)</a>:</h4>
<p>If I write some non-generic function <code>foo</code> in a crate lib, and use it from a crate bin, it's not inlined (until/without LTO), because bin only has the signature and symbol to work with.</p>



<a name="210628589"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210628589" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210628589">(Sep 19 2020 at 18:33)</a>:</h4>
<p>If it's marked <code>#[inline]</code>, however, it's treated similarly to generic code where MIR (and maybe some precompiled object code) from lib are provided to bin so that bin can inline <code>foo</code> during regular compilation</p>



<a name="210628684"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210628684" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210628684">(Sep 19 2020 at 18:35)</a>:</h4>
<p>On generic functions, <code>#[inline]</code> has a similar impact; without <code>#[inline]</code>, only a single copy of a given monomorphization is compiled per crate. With <code>#[inline]</code>, however, a copy of the monomorphization is in every compilation unit (of which there may be multiple per crate) for better application of inlining heuristics.</p>



<a name="210628706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210628706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christopher Durham <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210628706">(Sep 19 2020 at 18:35)</a>:</h4>
<p>(disclaimer: this info is recalled from things other people have said about <code>#[inline]</code>, not actual knowledge of how it's processed)</p>



<a name="210630029"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630029" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630029">(Sep 19 2020 at 19:01)</a>:</h4>
<p>Yeah the biggest single improvement would be to separate "inline this more often" from "make this inlinable at all please". And maybe people often use both at once, and <code>inline</code> can continue to be both at once, but if there was a way to <em>just</em> mark a function as inlinable without fiddling threshold for example that would be a simpler way to improve user control.</p>



<a name="210630046"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630046" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630046">(Sep 19 2020 at 19:02)</a>:</h4>
<p>or call site inline declaration. "This call here, inline it this time even if the function isn't normally inlined other places"</p>



<a name="210630133"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630133" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630133">(Sep 19 2020 at 19:03)</a>:</h4>
<p>"make this inlinable at all please" is <code>-Copt-level=2+</code>.</p>



<a name="210630188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630188">(Sep 19 2020 at 19:04)</a>:</h4>
<p>I have been told that is not the case for non-generic functions</p>



<a name="210630198"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630198" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630198">(Sep 19 2020 at 19:04)</a>:</h4>
<p>Well <code>-Copt-level=2+ -Clto=thin+</code>.</p>



<a name="210630204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630204">(Sep 19 2020 at 19:04)</a>:</h4>
<p>(if you need it to happen cross-cu)</p>



<a name="210630211"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630211" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630211">(Sep 19 2020 at 19:05)</a>:</h4>
<p>yes i do mean cross-crate</p>



<a name="210630297"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630297" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630297">(Sep 19 2020 at 19:06)</a>:</h4>
<p>duplicating function code across codegen units to achieve inlining is a significantly worse approach to the problem compared to doing it at the end with lto.</p>



<a name="210630312"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630312" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630312">(Sep 19 2020 at 19:06)</a>:</h4>
<p>then turn on whatever lto level does that by default in release builds</p>



<a name="210630325"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630325" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630325">(Sep 19 2020 at 19:07)</a>:</h4>
<p>Basically no normal user actually wants to think about codegen unit count or crate barriers or anything like this, they "just want it to work" in a release build.</p>



<a name="210630860"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630860" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630860">(Sep 19 2020 at 19:20)</a>:</h4>
<p>There's a semantic mismatch of sorts in that whether inlining should or can be done is not a local decision its mostly a global one. And so no local annotation can properly express what's proposed by the MCP here. There are some pre-existing projects that further erode the boundaries however (such as MIR-only rlibs), but ultimately anything that does so will result in everybody paying a cost in compile time. And its fairly clear to me at least that to most compile time matters more than better-specified inlining.</p>
<p>That’s why I don’t believe cross-crate LTO will ever be enabled by default. (And also why this proposal is somewhat under-researched perhaps and not super feasible)</p>



<a name="210630957"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210630957" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210630957">(Sep 19 2020 at 19:22)</a>:</h4>
<p><span class="user-mention silent" data-user-id="116458">Charles Lew</span> <a href="#narrow/stream/243200-t-lang.2Fmajor-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356/near/210624827">said</a>:</p>
<blockquote>
<div class="codehilite"><pre><span></span><code><span class="cp">#[inline(always)]</span><span class="w"></span>
<span class="k">fn</span> <span class="nf">foo</span><span class="p">()</span><span class="w"> </span><span class="p">{</span><span class="w">  </span><span class="n">foo</span><span class="p">()</span><span class="w"> </span><span class="p">}</span><span class="w"></span>
</code></pre></div>


<p>definitely will fail...</p>
</blockquote>
<p>Not necessarily. The compiler can first convert recursion into a loop and then inline the loop code for this function into the callers.</p>



<a name="210631044"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210631044" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210631044">(Sep 19 2020 at 19:24)</a>:</h4>
<p>Same holds for various cases of mutual recursion.</p>



<a name="210631345"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210631345" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210631345">(Sep 19 2020 at 19:31)</a>:</h4>
<p>Check/Debug compile time matters, and time to complete a Test suite run matters (both compile time <em>and</em> execution time combined), but rust should have the default for Release builds really should be "do everything you can, I'm gonna go get coffee".</p>
<p>And a particular project can <em>turn it down</em> if they want some sort of Release build that's faster to build at the expense of execution time. However, usually a release binary is build the once and executed hundreds or thousands of times, so that is what should get favored.</p>
<p>Or, heck, make an extra profile for "really release for real, i mean it"</p>



<a name="210631416"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210631416" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210631416">(Sep 19 2020 at 19:32)</a>:</h4>
<p>yeah, the extra profile thing has been proposed in the past (I believe it was called <code>deploy</code> or <code>distribute</code> or something along those lines? as in "for shipping to the clients")</p>



<a name="210631595"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210631595" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210631595">(Sep 19 2020 at 19:36)</a>:</h4>
<p>(its not only a compile _time_ tradeoff however, but a space one as well, and that's somewhat more difficult to mitigate by just making the trip to the coffee machine longer)</p>



<a name="210631623"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210631623" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nagisa <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210631623">(Sep 19 2020 at 19:37)</a>:</h4>
<p>If only we had some of those infinite Turing’s tapes!</p>



<a name="210631809"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210631809" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210631809">(Sep 19 2020 at 19:40)</a>:</h4>
<p>Obviously we give people a slider like in a video game where you favor either small binary at the expense of speed or the other way around ;P</p>



<a name="210632568"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210632568" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210632568">(Sep 19 2020 at 19:57)</a>:</h4>
<p>So I guess you could say I'm against this MCP because all inline hints are a necessary evil, not an inherent good. The mythical Sufficiently Smart Compiler would never need an inline hint to produce the perfect program. Of course we will likely never have such a compiler, so in the mean time we have inline as a band-aid. However, I think we should always consider it a band-aid, and try to remove the need for it, instead of making it further enshrined in the language as something people should use regularly.</p>



<a name="210634849"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210634849" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210634849">(Sep 19 2020 at 20:55)</a>:</h4>
<p>Having an "I really meant it" makes sense to me, but I think it might be better to make a new name for it so we can error about it.  Maybe <code>#[inline(required)]</code>?  As a new one we could make it an error to put that on a recursive function, for example -- giving warnings on <em>use</em> of the function is too much like monomorphization-time errors for my taste.</p>



<a name="210635024"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210635024" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210635024">(Sep 19 2020 at 20:59)</a>:</h4>
<p>That said, I also like <span class="user-mention" data-user-id="271719">@Mario Carneiro</span>'s point about "just use a macro" -- that's what Ralf had to do to get the perf of the slice iterators as good as they are, for example, as even trivial methods that LLVM did always inline was still just enough to impact the phase ordering and have the performance come out worse.</p>
<p>I've often pondered a middle-ground between functions and macros, one where you can only take values (like a function) but it's typed in the context of the caller at use (like a macro)...</p>



<a name="210702633"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210702633" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Charles Lew <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210702633">(Sep 21 2020 at 05:26)</a>:</h4>
<p>Hello, I've updated the MCP proposal text about the wordings here. I also like the <code>#[inline(required)]</code> idea, just that maybe it's a little churn to deprecate <code>#[inline(always)]</code> and migrate all existing <code>#[inline(always)]</code>usages.</p>



<a name="210703723"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210703723" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Josh Triplett <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210703723">(Sep 21 2020 at 05:53)</a>:</h4>
<p>Would it really cause breakage to just make <code>inline(always)</code> produce errors if it can't inline?</p>



<a name="210710115"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210710115" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210710115">(Sep 21 2020 at 07:48)</a>:</h4>
<p>I feel like it's got to be breaking for at least somebody -- I've seen plenty of people on Discord who like putting <code>#[inline(always)]</code> all over the place because they've seen just <code>#[inline]</code> not do what they wanted.</p>
<p>Thinking more, this seems like it'd be an easy edition change, though.  We could start warn-linting it immediately (it seems reasonable that legitimate uses of it would welcome such a warning) and then make it a hard error in a new edition.  (Or just deny-by-default, depending what the semantics people want are.)</p>
<p>That'd also be helpful in that such a lint could just be added without an MCP -- the usual check it in allow-by-default until it's known to work, then make it warn-by-default with just an FCP'd PR.</p>



<a name="210733699"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210733699" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210733699">(Sep 21 2020 at 12:30)</a>:</h4>
<p>I think my concern is still that we wouldn't be able to not produce warnings here until MIR inlining is in a better shape -- and even then, LLVM could "outline" code we inlined, in theory.</p>



<a name="210747295"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210747295" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210747295">(Sep 21 2020 at 14:16)</a>:</h4>
<p>We can still guess what LLVM is going to do and treat any mismatch as a rust bug though</p>



<a name="210747761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210747761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210747761">(Sep 21 2020 at 14:19)</a>:</h4>
<p>I think I would be opposed to adding linting until we can plausibly <em>fix</em> such bugs.</p>



<a name="210748624"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210748624" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210748624">(Sep 21 2020 at 14:25)</a>:</h4>
<p>well the "fix" in this setup would be to make the linting check more conservative</p>



<a name="210749036"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210749036" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210749036">(Sep 21 2020 at 14:28)</a>:</h4>
<p>but the claim is that most cases are in the gray area where we didn't inline it (because the MIR inliner isn't all there) but we have reasonable confidence that the LLVM inliner will follow our suggestion to inline, so a maximally conservative lint may well be unacceptable where an optimistic lint can perform quite well, possibly being refined as we find more LLVM edge cases</p>



<a name="210749073"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210749073" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210749073">(Sep 21 2020 at 14:28)</a>:</h4>
<p>hm, okay, maybe I'm misreading, but it seems to me that it loses value the more conservative it is. Basically what I'm trying to get at is that the implementation here seems really hard to get right -- maybe even essentially impossible. e.g., if someone casts a inline(required) or inline(always) to a function pointer, that's pretty unlikely to end up inlined (in general) -- is that considered a bug? should we lint on that cast?</p>



<a name="210749173"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210749173" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210749173">(Sep 21 2020 at 14:29)</a>:</h4>
<p>e.g., this lint seems like it would need to be a monomorphization time in codegen and maybe even per-callsite -- surely LLVM will have different inlining requirements depending on the caller</p>



<a name="210749349"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210749349" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210749349">(Sep 21 2020 at 14:31)</a>:</h4>
<blockquote>
<p>if someone casts a inline(required) or inline(always) to a function pointer, that's pretty unlikely to end up inlined (in general) -- is that considered a bug? should we lint on that cast?</p>
</blockquote>
<p>That sounds like a language definition problem. If <code>inline(required)</code> or whatever becomes a guaranteed part of rust then we need rules on what kinds of calls it applies to</p>



<a name="210750422"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210750422" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210750422">(Sep 21 2020 at 14:39)</a>:</h4>
<p>I don't actually know what would be the best option from a langauge design POV regarding inline(always) functions cast to pointers. If we silently drop the inlining requirement that could be a footgun, but if we error then it might make certain otherwise perfectly reasonable actions impossible, essentially putting them outside the regular type system. Since <code>#[inline(always)]</code> is an attribute and not a fundamental part of the function signature (which itself possibly needs cross analysis), any subsequent issues in usage should probably also be controlled by lint suppression attributes</p>



<a name="210773832"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210773832" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210773832">(Sep 21 2020 at 17:31)</a>:</h4>
<p><span class="user-mention" data-user-id="116122">@simulacrum</span> The narrowness of the guarantee we'd be willing to make is one reason I was thinking of this as a new kind of inline (strawman <code>#[inline(required)]</code>).  The idea would be like we've talked about with <code>become</code> for tail recursion: We just make the things we're not willing to promise yet not compile.  So yes, we'd do things like say "nope, can't get a function pointer to that" and "no, you can't call yourself (even unreachably) in such a function".</p>
<p>I don't know for sure what all those restrictions would need to be, but past-and-current bugs in the MIR inliner would probably give a good list of candidates for things to block <span aria-label="upside down" class="emoji emoji-1f643" role="img" title="upside down">:upside_down:</span></p>



<a name="210773980"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210773980" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> simulacrum <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210773980">(Sep 21 2020 at 17:32)</a>:</h4>
<p>Yeah, I think a new name for it would be necessary for that vs reusing always, but I could see us doing something like that. A bit unfortunate to have always and required, though.</p>



<a name="210785514"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210785514" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210785514">(Sep 21 2020 at 19:03)</a>:</h4>
<p>It's easy to explain though, "always" means "always try to (but move on if you can't)" and "required" means "actually error if you can't"</p>



<a name="210787803"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210787803" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> scottmcm <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210787803">(Sep 21 2020 at 19:21)</a>:</h4>
<p>Yeah, I guess since <code>#[inline]</code> is just "be <em>more</em> likely" there could still be a place for "please always try but it's not a correctness issue if sometimes you can't for some subtle reason".</p>



<a name="210808774"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210808774" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> tmandry <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210808774">(Sep 21 2020 at 22:35)</a>:</h4>
<p>Even if we inline things in MIR, LLVM has an <a href="https://reviews.llvm.org/D26872">outlining pass</a> that we can't prevent from running (IIUC, enabled by default on arm with <code>-Oz</code>)</p>



<a name="210829336"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829336" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829336">(Sep 22 2020 at 05:29)</a>:</h4>
<p>I'm still having trouble understanding how inlining can cause a correctness issue. LLVM obviously doesn't consider the possibility, or else they would have more strict controls on inlining</p>



<a name="210829467"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829467" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829467">(Sep 22 2020 at 05:32)</a>:</h4>
<p><span class="user-mention silent" data-user-id="224471">Lokathor</span> <a href="#narrow/stream/243200-t-lang.2Fmajor-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356/near/210624186">said</a>:</p>
<blockquote>
<p>I'd like to note that inline and inline(always) actually do make a <em>correctness</em> difference in the presence of cpu features. inline(always) <em>can</em> convince llvm to inline a different cpu featured function, while inline cannot.</p>
</blockquote>
<p>Certainly in the presence of architectural weirdness things like inlining can make observable differences, but not any more so than the usual compiler code motion</p>



<a name="210829544"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829544" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829544">(Sep 22 2020 at 05:34)</a>:</h4>
<p>you can, based on preliminary tests that <code>Amanieu</code> did, force LLVM to inline code across CPU feature differences. However, this can also do things like inline <code>t32</code> instruction set code into <code>a32</code> instruction set code.</p>



<a name="210829567"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829567" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829567">(Sep 22 2020 at 05:35)</a>:</h4>
<p>but, perhaps it's the case that there's safeguards elsewhere in the overall system to prevent actual problems. We just did a quick offhand check once when discussing the <code>instruction_set</code> RFC</p>



<a name="210829689"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829689" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829689">(Sep 22 2020 at 05:38)</a>:</h4>
<p>that sounds like it should be an LLVM bug</p>



<a name="210829722"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829722" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Lokathor <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829722">(Sep 22 2020 at 05:39)</a>:</h4>
<p>I suppose. We live in the world we got though.</p>



<a name="210829853"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829853" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829853">(Sep 22 2020 at 05:43)</a>:</h4>
<p>well as long as it is identified as an LLVM bug (violating LLVM's own language rules) we can just file the bug and work around it (or maybe even just do nothing since it seems pretty unlikely to come across this issue by accident), and the spec can go forward with inline(required) and a fairly optimistic linter</p>



<a name="210829933"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/243200-t-lang/major%20changes/topic/MCP%3A%20Rust-style%20%60%23%5Binline%5D%60%20attribute.%20lang-team%2356/near/210829933" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Mario Carneiro <a href="https://rust-lang.github.io/zulip_archive/stream/243200-t-lang/major-changes/topic/MCP.3A.20Rust-style.20.60.23.5Binline.5D.60.20attribute.2E.20lang-team.2356.html#210829933">(Sep 22 2020 at 05:45)</a>:</h4>
<p>If however the LLVM folks don't count it as a bug at all, because they have some theory for why their handling of inlining with cpu feature differences is reasonable, then we should think about how to match our spec to theirs, perhaps dropping <code>inline(required)</code> and instead patching whatever correctness holes are caused by inlining</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>